package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface shopCartMapper {

    List<ShoppingCart> list(ShoppingCart shoppingCart);

    @Update("update sky.shopping_cart set number = #{number} where user_id=#{userId}")
    void update(ShoppingCart cart);


    @Insert("insert into sky.shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time,number) VALUES " +
                                        "(#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime},#{number})")
    void save(ShoppingCart shoppingCart);


    @Delete("delete from sky.shopping_cart where user_id =#{userId}")
    void deleteByUserId(Long userId);

    @Delete("delete from sky.shopping_cart where id =#{id}")
    void deteById(Long id);

    void insertBatch(List<ShoppingCart> shoppingCartList);
}
